home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 July: Mac OS SDK / Dev.CD Jul 96 SDK / Dev.CD Jul 96 SDK2.toast / Development Kits (Disc 2) / QuickDraw GX / Programming Stuff / Sample Code / Typography Samples / Dave’s Fab Samples ƒ / Baseline Alignment.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-04-10  |  2.0 KB  |  85 lines  |  [TEXT/KAHL]

  1. #include <Types.h>
  2. #include <QuickDraw.h>
  3. #include <Fonts.h>
  4. #include <Windows.h>
  5. #include <Menus.h>
  6. #include <SegLoad.h>
  7. #include <Memory.h>
  8. #include <Desk.h>
  9.  
  10. #include "graphics routines.h"
  11. #include "graphics libraries.h"
  12. #include "graphics toolbox.h"
  13.  
  14. #include "layout types.h"
  15. #include "layout routines.h"
  16. #include "layout library.h"
  17.  
  18. #include "SampleInterface.h"
  19.  
  20.  
  21. short MyStrLen(char *x);
  22. static short MyStrLen(x)
  23. char    *x;
  24.     {
  25.     short c = 0;
  26.     while (*x++) c++;
  27.     return c;
  28.     }    /* MyStrLen */
  29.  
  30. void BaselineAlignment(WindowPtr sampleWindow)
  31.     {
  32.     /* Variables */
  33.     char                *myString = "Drop Caps";
  34.     gxLayoutOptions        gxLayoutOptions;
  35.     gxLineBaselineRecord    gxLineBaselineRecord;
  36.     gxPoint                myPoint;
  37.     gxRunControls            gxRunControls;
  38.     gxShape                layout;
  39.     short                len, level = 0, runLengths[4];
  40.     gxStyle                dropCapsStyle, regularStyle, styleArray[4];
  41.     gxViewPort            aViewPort;
  42.     
  43.     /* Initialization */
  44.     
  45.     myPoint.x = ff(20);
  46.     myPoint.y = ff(50);
  47.     
  48.     aViewPort = GXNewWindowViewPort(sampleWindow);
  49.     SetDefaultViewPort(aViewPort);
  50.     
  51.     len = MyStrLen(myString);
  52.     runLengths[0] = runLengths[2] = 1;
  53.     runLengths[1] = 4;
  54.     runLengths[3] = 3;
  55.     
  56.     regularStyle = NewLayoutStyle((char *) "\pHoefler Text", ff(40), 0, nil, nil, 0, nil);
  57.     
  58.     InitializeRunControls(&gxRunControls);
  59.     gxRunControls.baselineType = gxHangingBaseline;
  60.     dropCapsStyle = NewLayoutStyle((char *) "\pHoefler Text", ff(70), 0, &gxRunControls, nil, 0, nil);
  61.     
  62.     InitializeLayoutOptions(&gxLayoutOptions);
  63.     GXGetStyleBaselineDeltas(regularStyle, gxRomanBaseline, gxLineBaselineRecord.deltas);
  64.     gxLayoutOptions.baselineRec = &gxLineBaselineRecord;
  65.     
  66.     styleArray[0] = styleArray[2] = dropCapsStyle;
  67.     styleArray[1] = styleArray[3] = regularStyle;
  68.     
  69.     layout = GXNewLayout(
  70.         1, &len, (void *) &myString,
  71.         4, runLengths, styleArray,
  72.         1, &len, &level,
  73.         &gxLayoutOptions, &myPoint);
  74.     GXDrawShape(layout);
  75.     
  76.     GXSetStyleTextSize(dropCapsStyle, ff(110));
  77.     GXMoveShape(layout, 0, ff(100));
  78.     GXDrawShape(layout);
  79.     
  80.     GXDisposeShape(layout);
  81.     GXDisposeStyle(regularStyle);
  82.     GXDisposeStyle(dropCapsStyle);
  83.     GXDisposeViewPort(aViewPort);
  84.     }    /* main */
  85.